package com.timer;

import com.common.Constant;
import com.soecode.wxtools.bean.TemplateSender;
import com.soecode.wxtools.bean.result.TemplateSenderResult;
import com.soecode.wxtools.exception.WxErrorException;
import com.stock.StockMsg;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * Created by lzb on 2018/5/14.
 */
@Component
public class Timer {

    @Resource(name = "redisTemplate")
    private RedisTemplate redisTemplate;

    @Scheduled(fixedRate = 1000*60*10,initialDelay = 30000)
    public void scheduled1() throws WxErrorException {
        TemplateSender sender=StockMsg.checkWl(
                Arrays.asList(
                        (String[]) redisTemplate.opsForSet().members("oqcqkw8qmuLdS9qzm6p7oVhrIKPc").toArray(new  String[]{})
                ),
                Arrays.asList((String[]) redisTemplate.opsForSet().members("oqcqkw8qmuLdS9qzm6p7oVhrIKPc"+"_BUY").toArray(new  String[]{}))
        );
        if(sender!=null)Constant.iService.templateSend(sender);
    }
}
